package com.jk.cxh.controller;

import com.jk.OrderBean;
import com.jk.UserBean;
import com.jk.service.CxhUserServer;
import org.apache.http.protocol.HTTP;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @Author 程旭航
 * @Create 2021/5/23 - 14:38
 * @Description
 */
@Controller
@RequestMapping("page")
public class PageController {

    @Autowired
    private CxhUserServer cxhUserServer;


    //登陆页面
    @RequestMapping("login")
    public String login(){
        return "login";
    }

    //新增页面
    @RequestMapping("addUser")
    public String addUser(){
        return "addUser";
    }

    //修改页面
    @RequestMapping("upPwd")
    public String upPwd(){
        return "upPwd";
    }

    //我的中心页面
    @RequestMapping("myMessage")
    public String myMessage(Integer stu, Model model){
        model.addAttribute("stu",stu);
        return "myMessage";
    }

    ///注销登录
    @RequestMapping("logout")
    public String logout(HttpSession session){
        session.removeAttribute("user");
        cxhUserServer.logout();
        return "homepage/index2";
    }

    //查看详情
    @RequestMapping("details2")
    public String details(String orderId , Model model){

        //查询已付款详情
        OrderBean order= cxhUserServer.queryDetails(orderId);
        model.addAttribute("order",order);
        return "details";
    }



}
